package com.tuozixuan.mapstruct.mapping;

import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;

import com.tuozixuan.mapstruct.dto.UserDto;
import com.tuozixuan.mapstruct.model.User;

@Mapper(componentModel = "spring")
public interface UserMapper {
    
//    UserMapper INSTANCE = Mappers.getMapper(UserMapper.class);
    
    @Mappings({
//        @Mapping(source = "user.id",target = "id"),
        @Mapping(source = "user.birthDate",target = "birthDate", dateFormat="dd-MM-yyyy"),
    })
    UserDto toUserDto(User user);
    
    @Mappings({
      @Mapping(source = "birthDate",target = "birthDate", dateFormat="dd-MM-yyyy"),
  })
  User toUser(UserDto userDto);
}
